package com.lzy.permission.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="tb_role")
public class Role {
	
	@Id
	@Column(length=32)
	private String id ;
	
	@Column(length=64)
	private String code ;
	
	@Column(length=64,nullable=false)
	private String name ;
	
	@Column
	private int enabled ;
	
	@Column
	private int isAdmin ;
	
	@OneToMany
	@JoinTable(name="tb_role_resource",joinColumns={@JoinColumn(name="role_id")},
			   inverseJoinColumns={@JoinColumn(name="resource_id")} )
	private Set<Resource> resources = new HashSet<Resource>();
	
	public Set<Resource> getResources() {
		return resources;
	}

	public void setResources(Set<Resource> resources) {
		this.resources = resources;
	}

	public int getEnabled() {
		return enabled;
	}

	public void setEnabled(int enabled) {
		this.enabled = enabled;
	}

	public int getIsAdmin() {
		return isAdmin;
	}

	public void setIsAdmin(int isAdmin) {
		this.isAdmin = isAdmin;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
}
